/**********************************************************************
  The MIT License (MIT)
  Copyright (c) 2012 sunriseyuen

  Permission is hereby granted, free of charge, to any person obtaining
  a copy of this software and associated documentation files
  (the "Software"), to deal in the Software without restriction,
  including without limitation the rights to use, copy, modify, merge,
  publish, distribute, sublicense, and/or sell copies of the Software,
  and to permit persons to whom the Software is furnished to do so,
  subject to the following conditions:

  The above copyright notice and this permission notice shall be included
  in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
  THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 ***********************************************************************/

#define _DEF_CCY_CODE
#define _ZZDEBUG
#define _PROJ_DC

#region Using directives
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;

using Muki.Framework.Util;
using Muki.Framework.Business;
using Muki.Framework;
using Muki.UserDefine;
using Muki.Entity;
using Dot.StreamObject;

#endregion

namespace Muki.UserPanel
{
	public class UID02802AM:BLogic
	{
		public UID02802AM()
		{
			objDefault.UID_CODE    ="UID02802A";
		}

		public void Initialize()
		{
			objDefault.ZZLOGON_SSD = this.ZZLOGON_SSD;
			objDefault.Trans       = this.Trans;
			objDefault.ZZLOGON_ID  = this.ZZLOGON_ID;

			_Convert.ZZLOGON_SSD = this.ZZLOGON_SSD;
			_Convert.Trans       = this.Trans;

			_DataPermission.ZZLOGON_SSD = this.ZZLOGON_SSD;
			_DataPermission.Trans       = this.Trans;
			_DataPermission.TABLE_NAME  = "VQTHDTM";
			_DataPermission.ZZLOGON_ID  = this.ZZLOGON_ID;
			_DataPermission.DataAccessRight();

			_DocsPermission.ZZLOGON_SSD  = this.ZZLOGON_SSD;
			_DocsPermission.Trans        = this.Trans;

			_Setting.ZZLOGON_ID = this.ZZLOGON_ID;
			_Setting.Trans      = this.Trans;

		}

		public UID02802AE Verify(UID02802AE _Entity)
		{

						_Entity.VQT_NO=_Entity.VQT_NO.Trim();

					if (Util.IsNullOrEmpty(_Entity.ODTP_CODE))
					{
						_Entity.Exceptions.Add(new LogisticException("ODTP_CODE","DataMiss"));
					}

					if (Util.IsNullOrEmpty(_Entity.COMP_CODE))
					{
						_Entity.Exceptions.Add(new LogisticException("COMP_CODE","DataMiss"));
					}

					if (Util.IsNullOrEmpty(_Entity.BUYER_CODE))
					{
						_Entity.Exceptions.Add(new LogisticException("BUYER_CODE","DataMiss"));
					}

					if (Util.IsNullOrEmpty(_Entity.VEN_CODE))
					{
						_Entity.Exceptions.Add(new LogisticException("VEN_CODE","DataMiss"));
					}

					if (Util.IsNullOrEmpty(_Entity.VEN_TERM))
					{
						_Entity.Exceptions.Add(new LogisticException("VEN_TERM","DataMiss"));
					}

					if (Util.IsNullOrEmpty(_Entity.VQT_REQ_DATE))
					{
						_Entity.Exceptions.Add(new LogisticException("VQT_REQ_DATE","DataMiss"));
					}

					if (Util.IsNullOrEmpty(_Entity.CCY_CODE))
					{
						_Entity.Exceptions.Add(new LogisticException("CCY_CODE","DataMiss"));
					}

					if (Util.IsNullOrEmpty(_Entity.XCHG_RATE))
					{
						_Entity.Exceptions.Add(new LogisticException("XCHG_RATE","DataMiss"));
					}

				// Relation ZUODTPTM
			if (!Util.IsNullOrEmpty(_Entity.ODTP_CODE))
			{
			objRetrieveEntity=new CriteriaRetrieve(typeof(ZUODTPTMEntity));//单据类型
			objRetrieveEntity.Top=1;

			objCondition=objRetrieveEntity.NewCondition();
			objCondition.Equals("ODTP_CLASS_CODE","GLV");
			objCondition.Equals("ODTP_CODE",_Entity.ODTP_CODE);
				_DataPermission.TABLE_NAME="ZUODTPTM";
				_DataPermission.AccessCondition(objCondition);
			objEntityContainer=this.Trans.RetrieveEntitys(objRetrieveEntity);

			if (objEntityContainer.Count==0)
			{
				_Entity.Exceptions.Add(new LogisticException("ODTP_CODE","DataNotFd",_Entity.ODTP_CODE));
			}else{

					ZUODTPTMEntity objVZUODTPTMEntity=(ZUODTPTMEntity)objEntityContainer[0];
					if (objVZUODTPTMEntity.Verified)
					{
						 _Entity.ODTP_CODE=objVZUODTPTMEntity.ODTP_CODE;

					}else{
						_Entity.Exceptions.Add(new LogisticException("ODTP_CODE","DataNotFd",_Entity.ODTP_CODE));
					}
			}
			}
//ZUODTPTM

				// Relation ZNCOMPTM
			if (!Util.IsNullOrEmpty(_Entity.COMP_CODE))
			{
			objRetrieveEntity=new CriteriaRetrieve(typeof(ZNCOMPTMEntity));//公司资料表
			objRetrieveEntity.Top=1;

			objCondition=objRetrieveEntity.NewCondition();
			objCondition.Equals("COMP_CODE",_Entity.COMP_CODE);
				_DataPermission.TABLE_NAME="ZNCOMPTM";
				_DataPermission.AccessCondition(objCondition);
			objEntityContainer=this.Trans.RetrieveEntitys(objRetrieveEntity);

			if (objEntityContainer.Count==0)
			{
				_Entity.Exceptions.Add(new LogisticException("COMP_CODE","DataNotFd",_Entity.COMP_CODE));
			}else{

					ZNCOMPTMEntity objVZNCOMPTMEntity=(ZNCOMPTMEntity)objEntityContainer[0];
					if (objVZNCOMPTMEntity.Verified)
					{
						 _Entity.COMP_CODE=objVZNCOMPTMEntity.COMP_CODE;

					}else{
						_Entity.Exceptions.Add(new LogisticException("COMP_CODE","DataNotFd",_Entity.COMP_CODE));
					}
			}
			}
//ZNCOMPTM

				// Relation BUYERTM
			if (!Util.IsNullOrEmpty(_Entity.BUYER_CODE))
			{
			objRetrieveEntity=new CriteriaRetrieve(typeof(BUYERTMEntity));//采购员资料表
			objRetrieveEntity.Top=1;

			objCondition=objRetrieveEntity.NewCondition();
			objCondition.Equals("BUYER_CODE",_Entity.BUYER_CODE);
				_DataPermission.TABLE_NAME="BUYERTM";
				_DataPermission.AccessCondition(objCondition);
			objEntityContainer=this.Trans.RetrieveEntitys(objRetrieveEntity);

			if (objEntityContainer.Count==0)
			{
				_Entity.Exceptions.Add(new LogisticException("BUYER_CODE","DataNotFd",_Entity.BUYER_CODE));
			}else{

					BUYERTMEntity objVBUYERTMEntity=(BUYERTMEntity)objEntityContainer[0];
					if (objVBUYERTMEntity.Verified)
					{
						 _Entity.BUYER_CODE=objVBUYERTMEntity.BUYER_CODE;

					}else{
						_Entity.Exceptions.Add(new LogisticException("BUYER_CODE","DataNotFd",_Entity.BUYER_CODE));
					}
			}
			}
//BUYERTM

				// Relation VENRTBM
			if (!Util.IsNullOrEmpty(_Entity.VEN_CODE))
			{
			objRetrieveEntity=new CriteriaRetrieve(typeof(VENRTBMEntity));//供应商资料
			objRetrieveEntity.Top=1;

			objCondition=objRetrieveEntity.NewCondition();
			objCondition.Equals("VEN_CODE",_Entity.VEN_CODE);
				_DataPermission.TABLE_NAME="VENRTBM";
				_DataPermission.AccessCondition(objCondition);
			objEntityContainer=this.Trans.RetrieveEntitys(objRetrieveEntity);

			if (objEntityContainer.Count==0)
			{
				_Entity.Exceptions.Add(new LogisticException("VEN_CODE","DataNotFd",_Entity.VEN_CODE));
			}else{

					VENRTBMEntity objVVENRTBMEntity=(VENRTBMEntity)objEntityContainer[0];
					if (objVVENRTBMEntity.Verified)
					{
						 _Entity.VEN_CODE=objVVENRTBMEntity.VEN_CODE;

					}else{
						_Entity.Exceptions.Add(new LogisticException("VEN_CODE","DataNotFd",_Entity.VEN_CODE));
					}
			}
			}
//VENRTBM

				// Relation PMTCDTM
			if (!Util.IsNullOrEmpty(_Entity.VEN_TERM))
			{
			objRetrieveEntity=new CriteriaRetrieve(typeof(PMTCDTMEntity));//付款方式
			objRetrieveEntity.Top=1;

			objCondition=objRetrieveEntity.NewCondition();
			objCondition.Equals("PMT_CODE",_Entity.VEN_TERM);
				_DataPermission.TABLE_NAME="PMTCDTM";
				_DataPermission.AccessCondition(objCondition);
			objEntityContainer=this.Trans.RetrieveEntitys(objRetrieveEntity);

			if (objEntityContainer.Count==0)
			{
				_Entity.Exceptions.Add(new LogisticException("VEN_TERM","DataNotFd",_Entity.VEN_TERM));
			}else{

					PMTCDTMEntity objVPMTCDTMEntity=(PMTCDTMEntity)objEntityContainer[0];
					if (objVPMTCDTMEntity.Verified)
					{
						 _Entity.VEN_TERM=objVPMTCDTMEntity.PMT_CODE;

					}else{
						_Entity.Exceptions.Add(new LogisticException("VEN_TERM","DataNotFd",_Entity.VEN_TERM));
					}
			}
			}
//PMTCDTM

				// Relation CCYRTBM
			if (!Util.IsNullOrEmpty(_Entity.CCY_CODE))
			{
			objRetrieveEntity=new CriteriaRetrieve(typeof(CCYRTBMEntity));//货币资料表
			objRetrieveEntity.Top=1;

			objCondition=objRetrieveEntity.NewCondition();
			objCondition.Equals("CCY_CODE",_Entity.CCY_CODE);
				_DataPermission.TABLE_NAME="CCYRTBM";
				_DataPermission.AccessCondition(objCondition);
			objEntityContainer=this.Trans.RetrieveEntitys(objRetrieveEntity);

			if (objEntityContainer.Count==0)
			{
				_Entity.Exceptions.Add(new LogisticException("CCY_CODE","DataNotFd",_Entity.CCY_CODE));
			}else{

					CCYRTBMEntity objVCCYRTBMEntity=(CCYRTBMEntity)objEntityContainer[0];
					if (objVCCYRTBMEntity.Verified)
					{
						 _Entity.CCY_CODE=objVCCYRTBMEntity.CCY_CODE;

					}else{
						_Entity.Exceptions.Add(new LogisticException("CCY_CODE","DataNotFd",_Entity.CCY_CODE));
					}
			}
			}
//CCYRTBM

				// Relation PTERMTM
			if (!Util.IsNullOrEmpty(_Entity.PTERM_CODE))
			{
			objRetrieveEntity=new CriteriaRetrieve(typeof(PTERMTMEntity));//价格条款资料
			objRetrieveEntity.Top=1;

			objCondition=objRetrieveEntity.NewCondition();
			objCondition.Equals("PTERM_CODE",_Entity.PTERM_CODE);
				_DataPermission.TABLE_NAME="PTERMTM";
				_DataPermission.AccessCondition(objCondition);
			objEntityContainer=this.Trans.RetrieveEntitys(objRetrieveEntity);

			if (objEntityContainer.Count==0)
			{
				_Entity.Exceptions.Add(new LogisticException("PTERM_CODE","DataNotFd",_Entity.PTERM_CODE));
			}else{

					PTERMTMEntity objVPTERMTMEntity=(PTERMTMEntity)objEntityContainer[0];
					if (objVPTERMTMEntity.Verified)
					{
						 _Entity.PTERM_CODE=objVPTERMTMEntity.PTERM_CODE;

					}else{
						_Entity.Exceptions.Add(new LogisticException("PTERM_CODE","DataNotFd",_Entity.PTERM_CODE));
					}
			}
			}
//PTERMTM

				// Relation SVIATBM
			if (!Util.IsNullOrEmpty(_Entity.SVIA_CODE))
			{
			objRetrieveEntity=new CriteriaRetrieve(typeof(SVIATBMEntity));//送货途径
			objRetrieveEntity.Top=1;

			objCondition=objRetrieveEntity.NewCondition();
			objCondition.Equals("SVIA_CODE",_Entity.SVIA_CODE);
				_DataPermission.TABLE_NAME="SVIATBM";
				_DataPermission.AccessCondition(objCondition);
			objEntityContainer=this.Trans.RetrieveEntitys(objRetrieveEntity);

			if (objEntityContainer.Count==0)
			{
				_Entity.Exceptions.Add(new LogisticException("SVIA_CODE","DataNotFd",_Entity.SVIA_CODE));
			}else{

					SVIATBMEntity objVSVIATBMEntity=(SVIATBMEntity)objEntityContainer[0];
					if (objVSVIATBMEntity.Verified)
					{
						 _Entity.SVIA_CODE=objVSVIATBMEntity.SVIA_CODE;

					}else{
						_Entity.Exceptions.Add(new LogisticException("SVIA_CODE","DataNotFd",_Entity.SVIA_CODE));
					}
			}
			}
//SVIATBM

	if (_Entity.ATVT_CODE!="ADDNEW")
	{

		CriteriaRetrieve objValidateEntity=new CriteriaRetrieve(typeof(VQTHDTMEntity));
		objCondition=objValidateEntity.NewCondition();
		objCondition.Equals("VQT_NO",_Entity.VQT_NO);

		EntityObject objValidateObject=this.Trans.RetrieveEntity(objValidateEntity);

		if (objValidateObject!=null)
		{
			VQTHDTMEntity objVQTHDTMEntity=(VQTHDTMEntity)objValidateObject;
			if (objVQTHDTMEntity.ODTP_STATUS=="A")
			{
				throw new LogisticException("VQT_NO","Posted",_Entity.VQT_NO);
			}
		}else{
			throw new LogisticException("VQT_NO","DataNotFd",_Entity.VQT_NO);
		}
	}

				return _Entity;
		}

		public List<UID02802AE> Verify(List<UID02802AE> _Entitys)
		{
			List<UID02802AE> _New_Entitys=new List<UID02802AE>();

			foreach (UID02802AE _Entity in _Entitys) 
			{
				_New_Entitys.Add(Verify(_Entity));
			}
			return _New_Entitys;
		}

		public UID02802AE Default(UID02802AE _Entity)
		{

						_Entity.VQT_NO=objDefault.getDefault("VQT_NO",_Entity.VQT_NO);
						_Entity.ODTP_XREV=objDefault.getDefault("ODTP_XREV",_Entity.ODTP_XREV);
						_Entity.ODTP_STATUS=objDefault.getDefault("ODTP_STATUS",_Entity.ODTP_STATUS);
						_Entity.ODTP_CODE=objDefault.getDefault("ODTP_CODE",_Entity.ODTP_CODE);
						_Entity.COMP_CODE=objDefault.getDefault("COMP_CODE",_Entity.COMP_CODE);
						_Entity.BUYER_CODE=objDefault.getDefault("BUYER_CODE",_Entity.BUYER_CODE);
						_Entity.VEN_CODE=objDefault.getDefault("VEN_CODE",_Entity.VEN_CODE);
						_Entity.VEN_NAME01=objDefault.getDefault("VEN_NAME01",_Entity.VEN_NAME01);
						_Entity.VEN_TERM=objDefault.getDefault("VEN_TERM",_Entity.VEN_TERM);
						_Entity.VQT_REQ_DATE=objDefault.getDefault("VQT_REQ_DATE",_Entity.VQT_REQ_DATE);
						_Entity.CCY_CODE=objDefault.getDefault("CCY_CODE",_Entity.CCY_CODE);
						_Entity.PTERM_CODE=objDefault.getDefault("PTERM_CODE",_Entity.PTERM_CODE);
						_Entity.EXPIRY_DATE=objDefault.getDefault("EXPIRY_DATE",_Entity.EXPIRY_DATE);
						_Entity.XCHG_RATE=objDefault.getDefault("XCHG_RATE",_Entity.XCHG_RATE);
						_Entity.SVIA_CODE=objDefault.getDefault("SVIA_CODE",_Entity.SVIA_CODE);
						_Entity.VQT_ODTP_RMKS=objDefault.getDefault("VQT_ODTP_RMKS",_Entity.VQT_ODTP_RMKS);

					// WriteDefault CCYRTBM
ZZTrace.Debug(ZFILE_NAME,"_Entity.CCY_CODE="+_Entity.CCY_CODE);
			if (!Util.IsNullOrEmpty(_Entity.CCY_CODE))
			{
			objRetrieveEntity=new CriteriaRetrieve(typeof(CCYRTBMEntity));//货币资料表
			objRetrieveEntity.Top=1;

			objCondition=objRetrieveEntity.NewCondition();
			objCondition.Equals("CCY_CODE",_Entity.CCY_CODE);
				_DataPermission.TABLE_NAME="CCYRTBM";
				_DataPermission.AccessCondition(objCondition);
			objEntityContainer=this.Trans.RetrieveEntitys(objRetrieveEntity);

ZZTrace.Debug(ZFILE_NAME,"CCYRTBM"+objEntityContainer.Count);
			if (objEntityContainer.Count>0)
			{

					CCYRTBMEntity objDCCYRTBMEntity=(CCYRTBMEntity)objEntityContainer[0];
					if (objDCCYRTBMEntity.Verified)
					{
						 _Entity.CCY_CODE=objDCCYRTBMEntity.CCY_CODE;
						 _Entity.XCHG_RATE=objDCCYRTBMEntity.XCHG_RATE;

					}else{
					}
			}else{
			}
			}

				return _Entity;
		}

		public List<UID02802AE> Default(List<UID02802AE> _Entitys)
		{
			List<UID02802AE> _New_Entitys=new List<UID02802AE>();
			foreach (UID02802AE _Entity in _Entitys) 
			{
				_New_Entitys.Add(Default(_Entity));
			}
			return _New_Entitys;
		}

		public UID02802AE Search(VContexts _VContexts,UID02802AE _Entity)
		{

			if (_DocsPermission.AccessRight("UID02802A", this.ZZLOGON_ID, "ACCESS")==false)
			{
				_Entity.Exceptions.Add(new LogisticException("UID02802A","NotAccessRight", this.ZZLOGON_ID));
				return _Entity;
			}

			ZZSQLStatement  _SQLStatement = new ZZSQLStatement();

			_SQLStatement.Trans         = this.Trans;
			_SQLStatement.UID_CODE      = "UID02802A";
			_SQLStatement.ZZLOGON_SSD   = this.ZZLOGON_SSD;
			_SQLStatement.ZZLOGON_LANG  = this.ZZLOGON_LANG;
			_SQLStatement.DbName        = this.DbName;
			_SQLStatement.Process("QID02802A");

			ZZQLite oZZQLite = _SQLStatement.oZZQLite;

			if (_VContexts.getValue("T1")!="" && _VContexts.getValue("V1")!="")
			{
				oZZQLite.AddXWhereClause("", _VContexts.getValue("T1"), _VContexts.getValue("V1"));
			}
			if (_VContexts.getValue("T2")!="" && _VContexts.getValue("V2")!="")
			{
				oZZQLite.AddXWhereClause("", _VContexts.getValue("T2"), _VContexts.getValue("V2"));
			}
			if (_VContexts.getValue("T3")!="" && _VContexts.getValue("V3")!="")
			{
				oZZQLite.AddXWhereClause("", _VContexts.getValue("T3"), _VContexts.getValue("V3"));
			}

			if (!Util.IsNullOrEmpty(_VContexts.getValue("lookup")))
			{
				oZZQLite.AddXWhereClause("A", "", _VContexts.getValue("lookup"));
			}

			oZZQLite.Condition=_VContexts.getValue("Condition");
			oZZQLite.Make();

			int _AbsolutePage = _VContexts.getInteger("AbsolutePage");
			int _PageSize     = _VContexts.getInteger("ZZPageSize");
			int _Restrict     = _VContexts.getInteger("Restrict");
			int _TotalPages   = 0;

			_Setting.Trans      = this.Trans;

			if (_Restrict == 0)
			{
				_Restrict=30;
			}

			if (_PageSize <= 0)
			{
				_PageSize=_Setting.getInteger("ZZPageSize","20");
			}

				QueryRows RsVQTHDTM   = new QueryRows(this.Trans);
			RsVQTHDTM.CommandText = oZZQLite.SQLStatement;
			RsVQTHDTM.Top         = _Restrict;
			RsVQTHDTM.Skip        = (_AbsolutePage-1)*_PageSize;
			RsVQTHDTM.Limit       = _PageSize;
			RsVQTHDTM.CountAll    = true;
			RsVQTHDTM.Open();

			if (_PageSize <= 0)
			{
				_TotalPages   = RsVQTHDTM.RecordCount;
				_PageSize = RsVQTHDTM.RecordCount;
			}
			else
			{
				_TotalPages= RsVQTHDTM.RecordCount / _PageSize;
			}
			if (RsVQTHDTM.RecordCount > (RsVQTHDTM.RecordCount / _PageSize) * _PageSize)
			{
				_TotalPages = _TotalPages+ 1;
			}

			if (_AbsolutePage <= 0)
			{
				_AbsolutePage = 1;
			}

			if (_AbsolutePage > _TotalPages)
			{
				_AbsolutePage = _TotalPages;
			}

			Wxf _Wxf  = new Wxf();

			_Wxf.XDeclareStart();
			foreach(AttributeMapping _AttributeMapping in oZZQLite.AttributeMappings)
			{
				if (_AttributeMapping.STATUS_CODE != "HIDDEN")
				{
					_Wxf.XDeclare(_AttributeMapping);
				}
			}
			_Wxf.XDeclareFinal();

			_Wxf.Variable("ZZPageSize",_PageSize);
			_Wxf.Variable("ZZPages",_TotalPages);
			_Wxf.Variable("USQL_CODE","QID02802A");

			while (!RsVQTHDTM.EOF)
			{
				string cPickUpData   = "";
				object cValue;

				_Wxf.AddNew();
				int i=0;
				foreach(AttributeMapping _AttributeMapping in oZZQLite.AttributeMappings)
				{

					cValue = RsVQTHDTM[i];

					if (_AttributeMapping.STATUS_CODE != "HIDDEN")
					{
						_Wxf[_AttributeMapping.Name] = cValue;
					}

					if (_AttributeMapping.PrimaryKey)
					{
						if (cPickUpData != "")
						{
							cPickUpData = cPickUpData + "|";
						}
						cPickUpData = cPickUpData + ZZGeneral.Base64Encoder(_AttributeMapping.ColumnName + "=" + cValue);
					}
					i++;
				}

				_Wxf.PK_DATA   = cPickUpData;
				_Wxf.Update();

				RsVQTHDTM.MoveNext();
			}
			RsVQTHDTM.Close();

			_Entity.Wxf=_Wxf;

			return _Entity;
		}

		public UID02802AE Retrieves(VContexts _VContexts,UID02802AE _Entity)
		{
			if (_DocsPermission.AccessRight("UID02802A", this.ZZLOGON_ID, "ACCESS")==false)
			{
				_Entity.Exceptions.Add(new LogisticException("UID02802A","NotAccessRight",this.ZZLOGON_ID));
				return _Entity;
			}

			List<UID02802AE> _New_Entitys=new List<UID02802AE>();

				CriteriaRetrieve objRetrieveVQTHDTMEntity=new CriteriaRetrieve(typeof(VQTHDTMEntity));

			objRetrieveVQTHDTMEntity.Top=1;
			objCondition=objRetrieveVQTHDTMEntity.NewCondition();

			bool ZZOrderByAsc=_Setting.getBoolean("ZZOrderByAsc","YES");
			switch (_VContexts.getValue("UDEF_CODE"))
			{
				case "MF":
					{
						objRetrieveVQTHDTMEntity.OrderBy("VQT_NO",ZZOrderByAsc);
						break;
					}
				case "ML":
					{
						objRetrieveVQTHDTMEntity.OrderBy("VQT_NO",!ZZOrderByAsc);
						break;
					}
				case "MN":
					{
						if (ZZOrderByAsc)
						{
							objCondition.GreaterThan("VQT_NO",_Entity.VQT_NO);
						}else{
							objCondition.LessThan("VQT_NO",_Entity.VQT_NO);
						}
						objRetrieveVQTHDTMEntity.OrderBy("VQT_NO",ZZOrderByAsc);
						break;
					}
				case "MP":
					{
						if (ZZOrderByAsc)
						{
							objCondition.LessThan("VQT_NO",_Entity.VQT_NO);
						}else{
							objCondition.GreaterThan("VQT_NO",_Entity.VQT_NO);
						}
						objRetrieveVQTHDTMEntity.OrderBy("VQT_NO",!ZZOrderByAsc);
						break;
					}
				case "CANCEL":
					{
						objRetrieveVQTHDTMEntity.OrderBy("VQT_NO",ZZOrderByAsc);
						_Entity.DATA_STATUS_CODE="Verified";
						break;
					}
				case "LOOKUP":
					{
						objRetrieveVQTHDTMEntity.OrderBy("VQT_NO",ZZOrderByAsc);
						break;
					}

				case "ACTIVETAB":
					{
								if (_Entity.VQT_NO != "")
								{
									objCondition.Equals("VQT_NO", _Entity.VQT_NO);
								}

						objRetrieveVQTHDTMEntity.OrderBy("VQT_NO",ZZOrderByAsc);
						break;
					}

				case "READ":
					{
								objCondition.Equals("VQT_NO", _Entity.VQT_NO);
						break;
					}					
				default:
					{
								if (_Entity.VQT_NO != "")
								{
									objCondition.Equals("VQT_NO", _Entity.VQT_NO);
								}
						objRetrieveVQTHDTMEntity.OrderBy("VQT_NO",ZZOrderByAsc);

						break;
					}
			}

			//filter by quick look
			string _LOOUP_COLUMN_NAME=";VQTHDTM.VQT_NO;VQTHDTM.ODTP_STATUS;VQTHDTM.ODTP_CODE;VQTHDTM.COMP_CODE;VQTHDTM.BUYER_CODE;VQTHDTM.VEN_CODE;VQTHDTM.VEN_TERM;VQTHDTM.CCY_CODE;VQTHDTM.PTERM_CODE;VQTHDTM.SVIA_CODE;VQTHDTM.VQT_ODTP_RMKS";
			string lookup=_VContexts.getValue("lookup");
			_LOOUP_COLUMN_NAME=_LOOUP_COLUMN_NAME+";";
			if (lookup!="")
			{
				Condition _Condition2=objCondition.NewCondition(" AND ");
				foreach (string s in _LOOUP_COLUMN_NAME.Split(new char[] { ';' }))
				{
					if (!string.IsNullOrEmpty(s))
					{
						Condition OrCondition=_Condition2.NewCondition();
						OrCondition.Expression(s,lookup);
					}
				}
			}

			//filter by filters

				//filter by AccessConditions
				_DataPermission.AccessCondition(objCondition);

			VQTHDTMEntity objVQTHDTMs=(VQTHDTMEntity)this.Trans.RetrieveEntity(objRetrieveVQTHDTMEntity);

			ZZTrace.Debug(ZFILE_NAME,"SELECT="+objRetrieveVQTHDTMEntity.SELECTClause);

			if (objVQTHDTMs==null && _VContexts.getValue("UDEF_CODE")=="MN")
			{
				_Entity.Exceptions.Add(new LogisticException("VQT_NO","DataEOF"));
				return _Entity;
			}else if (objVQTHDTMs==null && _VContexts.getValue("UDEF_CODE")=="MP")
			{
				_Entity.Exceptions.Add(new LogisticException("VQT_NO","DataBOF"));
				return _Entity;
			}else if (objVQTHDTMs==null && (_VContexts.getValue("UDEF_CODE")=="MF" || _VContexts.getValue("UDEF_CODE")=="ML") )
			{
				_Entity.Exceptions.Add(new LogisticException("VQT_NO","DataBlank"));
				return _Entity;
			}else if (objVQTHDTMs==null && _VContexts.getValue("UDEF_CODE")=="LOOKUP")
			{
				/*
				 *if (this.COLUMN_REFX.IndexOf(";")>=0)
				 *{
				 *}else{
				 *    string _T_COLUMN_REFX=this.COLUMN_REFX;
				 *    if (_T_COLUMN_REFX.IndexOf('.') > 0)
				 *    {
				 *        string[] s = _T_COLUMN_REFX.Split(new char[] { '.' });
				 *        _T_COLUMN_REFX=s[1];
				 *    }
				 *    _Entity.Exceptions.Add(new LogisticException(_T_COLUMN_REFX,"DataNotFd","DataBlank"));
				 *    return _Entity;
				 *}
				 */
			}else if (objVQTHDTMs==null && _VContexts.getValue("UDEF_CODE")=="ACTIVETAB")
			{
				//throw new LogisticException("VQT_NO","Activetab","");
				//this.Default(_Entity);
			}else if (objVQTHDTMs==null)
			{
				//this.Default(_Entity);
			}else{
				VQTHDTMEntity objVQTHDTMEntity = objVQTHDTMs;
					ZZTrace.MUKI_DEBUG_LOG=true;
						_Entity.VQT_NO=objVQTHDTMEntity.VQT_NO;
						_Entity.ODTP_XREV=objVQTHDTMEntity.ODTP_XREV;
						_Entity.ODTP_STATUS=objVQTHDTMEntity.ODTP_STATUS;
						_Entity.ODTP_CODE=objVQTHDTMEntity.ODTP_CODE;
						_Entity.COMP_CODE=objVQTHDTMEntity.COMP_CODE;
						_Entity.BUYER_CODE=objVQTHDTMEntity.BUYER_CODE;
						_Entity.VEN_CODE=objVQTHDTMEntity.VEN_CODE;
						_Entity.VEN_TERM=objVQTHDTMEntity.VEN_TERM;
						_Entity.VQT_REQ_DATE=objVQTHDTMEntity.VQT_REQ_DATE;
						_Entity.CCY_CODE=objVQTHDTMEntity.CCY_CODE;
						_Entity.PTERM_CODE=objVQTHDTMEntity.PTERM_CODE;
						_Entity.EXPIRY_DATE=objVQTHDTMEntity.EXPIRY_DATE;
						_Entity.XCHG_RATE=objVQTHDTMEntity.XCHG_RATE;
						_Entity.SVIA_CODE=objVQTHDTMEntity.SVIA_CODE;
						_Entity.VQT_ODTP_RMKS=objVQTHDTMEntity.VQT_ODTP_RMKS;

				_Entity.UZADD_DATE     =_Convert.ToDateTimeString(objVQTHDTMEntity.ZADD_DATE);
_Entity.UZADD_USER     =objVQTHDTMEntity.ZADD_USER;
_Entity.UZCHG_DATE     =_Convert.ToDateTimeString(objVQTHDTMEntity.ZCHG_DATE);
_Entity.UZCHG_USER     =objVQTHDTMEntity.ZCHG_USER;
_Entity.USECURITY_CODE1=objVQTHDTMEntity.ZSECURITY_CODE1;
_Entity.USECURITY_CODE2=objVQTHDTMEntity.ZSECURITY_CODE2;
_Entity.USECURITY_CODE3=objVQTHDTMEntity.ZSECURITY_CODE3;
_Entity.USECURITY_CODE4=objVQTHDTMEntity.ZSECURITY_CODE4;
_Entity.USECURITY_CODE5=objVQTHDTMEntity.ZSECURITY_CODE5;
_Entity.USECURITY_CODE6=objVQTHDTMEntity.ZSECURITY_CODE6;

					// WriteDefault VENRTBM
ZZTrace.Debug(ZFILE_NAME,"_Entity.VEN_CODE="+_Entity.VEN_CODE);
			if (!Util.IsNullOrEmpty(_Entity.VEN_CODE))
			{
			objRetrieveEntity=new CriteriaRetrieve(typeof(VENRTBMEntity));//供应商资料
			objRetrieveEntity.Top=1;

			objCondition=objRetrieveEntity.NewCondition();
			objCondition.Equals("VEN_CODE",_Entity.VEN_CODE);
				_DataPermission.TABLE_NAME="VENRTBM";
				_DataPermission.AccessCondition(objCondition);
			objEntityContainer=this.Trans.RetrieveEntitys(objRetrieveEntity);

ZZTrace.Debug(ZFILE_NAME,"VENRTBM"+objEntityContainer.Count);
			if (objEntityContainer.Count>0)
			{

					VENRTBMEntity objDVENRTBMEntity=(VENRTBMEntity)objEntityContainer[0];
					if (objDVENRTBMEntity.Verified)
					{
						 _Entity.VEN_CODE=objDVENRTBMEntity.VEN_CODE;
						 _Entity.VEN_NAME01=objDVENRTBMEntity.VEN_NAME01;

					}else{
					}
			}else{
			}
			}

					_Entity.DATA_STATUS_CODE="Verified";
			}
				return _Entity;
		}

		public  UID02802AE AddNew(UID02802AE _Entity)
		{

			ZZTrace.Debug(ZFILE_NAME,"ZZLOGON_ID="+this.ZZLOGON_ID);

			if (_DocsPermission.AccessRight("UID02802A", this.ZZLOGON_ID, "ADDNEW")==false)
			{
				_Entity.Exceptions.Add(new LogisticException("UID02802A","NotAddNewRight",this.ZZLOGON_ID));
				return _Entity;
			}

			_Entity.ATVT_CODE="ADDNEW";

				_Entity=this.Verify(_Entity);
			if (_Entity.Exceptions.Count>0)
			{
				return _Entity;
			}
			VQTHDTMEntity objAddNewEntity=new VQTHDTMEntity();

			ZZHDKeyLib objZZHDKeyLib=new ZZHDKeyLib();
			objZZHDKeyLib.Trans=this.Trans;
					objZZHDKeyLib.COMP_CODE       = _Entity.COMP_CODE;
					objZZHDKeyLib.ODTP_CODE       = _Entity.ODTP_CODE;
					objZZHDKeyLib.ODTP_CLASS_CODE = "VQ";
					objZZHDKeyLib.Process();
				_Entity.VQT_NO = objZZHDKeyLib.ORD_NO;

					objAddNewEntity.VQT_NO=_Entity.VQT_NO;

			this.Trans.RetrieveEntity(objAddNewEntity);

			if (objAddNewEntity.Verified)
			{
				_Entity.Exceptions.Add(new LogisticException("VQT_NO","DataExist",_Entity.VQT_NO));
				return _Entity;
			}else{

				objAddNewEntity.ZADD_DATE = DateTime.Now;
				objAddNewEntity.ZADD_USER = this.ZZLOGON_ID;

				_DataPermission.TABLE_NAME="VQTHDTM";
				_DataPermission.DataAccessRight();
				objAddNewEntity.ZSECURITY_CODE1 = _DataPermission.ACCESS_AUTH.getValue("SECURITY_CODE1");
				objAddNewEntity.ZSECURITY_CODE2 = _DataPermission.ACCESS_AUTH.getValue("SECURITY_CODE2");
				objAddNewEntity.ZSECURITY_CODE3 = _DataPermission.ACCESS_AUTH.getValue("SECURITY_CODE3");
				objAddNewEntity.ZSECURITY_CODE4 = _DataPermission.ACCESS_AUTH.getValue("SECURITY_CODE4");
				objAddNewEntity.ZSECURITY_CODE5 = _DataPermission.ACCESS_AUTH.getValue("SECURITY_CODE5");
				objAddNewEntity.ZSECURITY_CODE6 = _DataPermission.ACCESS_AUTH.getValue("SECURITY_CODE6");
				objAddNewEntity.ZSECURITY_RIGHT = _DataPermission.ACCESS_AUTH.getInteger("SECURITY_RIGHT");

				_Entity.UZADD_DATE     =_Convert.ToDateTimeString(objAddNewEntity.ZADD_DATE);
_Entity.UZADD_USER     =objAddNewEntity.ZADD_USER;
_Entity.UZCHG_DATE     =_Convert.ToDateTimeString(objAddNewEntity.ZCHG_DATE);
_Entity.UZCHG_USER     =objAddNewEntity.ZCHG_USER;
_Entity.USECURITY_CODE1=objAddNewEntity.ZSECURITY_CODE1;
_Entity.USECURITY_CODE2=objAddNewEntity.ZSECURITY_CODE2;
_Entity.USECURITY_CODE3=objAddNewEntity.ZSECURITY_CODE3;
_Entity.USECURITY_CODE4=objAddNewEntity.ZSECURITY_CODE4;
_Entity.USECURITY_CODE5=objAddNewEntity.ZSECURITY_CODE5;
_Entity.USECURITY_CODE6=objAddNewEntity.ZSECURITY_CODE6;

							objAddNewEntity.VQT_NO=_Entity.VQT_NO;
							objAddNewEntity.ODTP_XREV=_Entity.ODTP_XREV;
							objAddNewEntity.ODTP_STATUS=_Entity.ODTP_STATUS;
							objAddNewEntity.ODTP_CODE=_Entity.ODTP_CODE;
							objAddNewEntity.COMP_CODE=_Entity.COMP_CODE;
							objAddNewEntity.BUYER_CODE=_Entity.BUYER_CODE;
							objAddNewEntity.VEN_CODE=_Entity.VEN_CODE;
							objAddNewEntity.VEN_TERM=_Entity.VEN_TERM;
							objAddNewEntity.VQT_REQ_DATE=_Entity.VQT_REQ_DATE;
							objAddNewEntity.CCY_CODE=_Entity.CCY_CODE;
							objAddNewEntity.PTERM_CODE=_Entity.PTERM_CODE;
							objAddNewEntity.EXPIRY_DATE=_Entity.EXPIRY_DATE;
							objAddNewEntity.XCHG_RATE=_Entity.XCHG_RATE;
							objAddNewEntity.SVIA_CODE=_Entity.SVIA_CODE;
							objAddNewEntity.VQT_ODTP_RMKS=_Entity.VQT_ODTP_RMKS;
			}

	_Entity.ODTP_STATUS="Draft";
	objAddNewEntity.ODTP_STATUS = _Entity.ODTP_STATUS;

				this.Trans.SaveChanges(objAddNewEntity);

				// WriteDefault VENRTBM
ZZTrace.Debug(ZFILE_NAME,"_Entity.VEN_CODE="+_Entity.VEN_CODE);
			if (!Util.IsNullOrEmpty(_Entity.VEN_CODE))
			{
			objRetrieveEntity=new CriteriaRetrieve(typeof(VENRTBMEntity));//供应商资料
			objRetrieveEntity.Top=1;

			objCondition=objRetrieveEntity.NewCondition();
			objCondition.Equals("VEN_CODE",_Entity.VEN_CODE);
				_DataPermission.TABLE_NAME="VENRTBM";
				_DataPermission.AccessCondition(objCondition);
			objEntityContainer=this.Trans.RetrieveEntitys(objRetrieveEntity);

ZZTrace.Debug(ZFILE_NAME,"VENRTBM"+objEntityContainer.Count);
			if (objEntityContainer.Count>0)
			{

					VENRTBMEntity objDVENRTBMEntity=(VENRTBMEntity)objEntityContainer[0];
					if (objDVENRTBMEntity.Verified)
					{
						 _Entity.VEN_CODE=objDVENRTBMEntity.VEN_CODE;
						 _Entity.VEN_NAME01=objDVENRTBMEntity.VEN_NAME01;

					}else{
					}
			}else{
			}
			}

				_Entity.DATA_STATUS_CODE="Verified";
			return _Entity;
		}

		public  UID02802AE Update(UID02802AE _Entity)
		{

			if (_DocsPermission.AccessRight("UID02802A", this.ZZLOGON_ID, "UPDATE")==false)
			{
				_Entity.Exceptions.Add(new LogisticException("UID02802A","NotUpdateRight",this.ZZLOGON_ID));
				return _Entity;
			}
			_Entity.ATVT_CODE="UPDATE";

						if (_Entity.VQT_NO=="")
						{
							_Entity.Exceptions.Add(new LogisticException("VQT_NO","DataMiss",""));
						}

			_Entity=this.Verify(_Entity);
			ZZTrace.Debug(ZFILE_NAME,"_Entity.Exceptions.Count="+_Entity.Exceptions.Count);
			if (_Entity.Exceptions.Count>0)
			{
				return _Entity;
			}

					//ZZTrace.Debug(ZFILE_NAME,"_Entity.VQT_NO="+_Entity.VQT_NO);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.ODTP_XREV="+_Entity.ODTP_XREV);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.ODTP_STATUS="+_Entity.ODTP_STATUS);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.ODTP_CODE="+_Entity.ODTP_CODE);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.COMP_CODE="+_Entity.COMP_CODE);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.BUYER_CODE="+_Entity.BUYER_CODE);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.VEN_CODE="+_Entity.VEN_CODE);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.VEN_TERM="+_Entity.VEN_TERM);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.VQT_REQ_DATE="+_Entity.VQT_REQ_DATE);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.CCY_CODE="+_Entity.CCY_CODE);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.PTERM_CODE="+_Entity.PTERM_CODE);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.EXPIRY_DATE="+_Entity.EXPIRY_DATE);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.XCHG_RATE="+_Entity.XCHG_RATE);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.SVIA_CODE="+_Entity.SVIA_CODE);
					//ZZTrace.Debug(ZFILE_NAME,"_Entity.VQT_ODTP_RMKS="+_Entity.VQT_ODTP_RMKS);

			objRetrieveEntity=new CriteriaRetrieve(typeof(VQTHDTMEntity));
			objCondition=objRetrieveEntity.NewCondition();

					objCondition.Equals("VQT_NO", _Entity.VQT_NO);

			_DataPermission.UpdateCondition(objCondition);

			EntityObject objEntityObject=this.Trans.RetrieveEntity(objRetrieveEntity);

			if (objEntityObject != null)
			{
				VQTHDTMEntity objUpdateEntity=(VQTHDTMEntity)objEntityObject;
				if (objUpdateEntity.Verified)
				{
					objUpdateEntity.ZCHG_DATE=DateTime.Now;
					objUpdateEntity.ZCHG_USER=this.ZZLOGON_ID;

								objUpdateEntity.VQT_NO=_Entity.VQT_NO;
								objUpdateEntity.ODTP_XREV=_Entity.ODTP_XREV;
								objUpdateEntity.ODTP_STATUS=_Entity.ODTP_STATUS;
								objUpdateEntity.ODTP_CODE=_Entity.ODTP_CODE;
								objUpdateEntity.COMP_CODE=_Entity.COMP_CODE;
								objUpdateEntity.BUYER_CODE=_Entity.BUYER_CODE;
								objUpdateEntity.VEN_CODE=_Entity.VEN_CODE;
								objUpdateEntity.VEN_TERM=_Entity.VEN_TERM;
								objUpdateEntity.VQT_REQ_DATE=_Entity.VQT_REQ_DATE;
								objUpdateEntity.CCY_CODE=_Entity.CCY_CODE;
								objUpdateEntity.PTERM_CODE=_Entity.PTERM_CODE;
								objUpdateEntity.EXPIRY_DATE=_Entity.EXPIRY_DATE;
								objUpdateEntity.XCHG_RATE=_Entity.XCHG_RATE;
								objUpdateEntity.SVIA_CODE=_Entity.SVIA_CODE;
								objUpdateEntity.VQT_ODTP_RMKS=_Entity.VQT_ODTP_RMKS;

						this.Trans.SaveChanges(objUpdateEntity);

						// WriteDefault VENRTBM
ZZTrace.Debug(ZFILE_NAME,"_Entity.VEN_CODE="+_Entity.VEN_CODE);
			if (!Util.IsNullOrEmpty(_Entity.VEN_CODE))
			{
			objRetrieveEntity=new CriteriaRetrieve(typeof(VENRTBMEntity));//供应商资料
			objRetrieveEntity.Top=1;

			objCondition=objRetrieveEntity.NewCondition();
			objCondition.Equals("VEN_CODE",_Entity.VEN_CODE);
				_DataPermission.TABLE_NAME="VENRTBM";
				_DataPermission.AccessCondition(objCondition);
			objEntityContainer=this.Trans.RetrieveEntitys(objRetrieveEntity);

ZZTrace.Debug(ZFILE_NAME,"VENRTBM"+objEntityContainer.Count);
			if (objEntityContainer.Count>0)
			{

					VENRTBMEntity objDVENRTBMEntity=(VENRTBMEntity)objEntityContainer[0];
					if (objDVENRTBMEntity.Verified)
					{
						 _Entity.VEN_CODE=objDVENRTBMEntity.VEN_CODE;
						 _Entity.VEN_NAME01=objDVENRTBMEntity.VEN_NAME01;

					}else{
					}
			}else{
			}
			}

						_Entity.UZADD_DATE     =_Convert.ToDateTimeString(objUpdateEntity.ZADD_DATE);
_Entity.UZADD_USER     =objUpdateEntity.ZADD_USER;
_Entity.UZCHG_DATE     =_Convert.ToDateTimeString(objUpdateEntity.ZCHG_DATE);
_Entity.UZCHG_USER     =objUpdateEntity.ZCHG_USER;
_Entity.USECURITY_CODE1=objUpdateEntity.ZSECURITY_CODE1;
_Entity.USECURITY_CODE2=objUpdateEntity.ZSECURITY_CODE2;
_Entity.USECURITY_CODE3=objUpdateEntity.ZSECURITY_CODE3;
_Entity.USECURITY_CODE4=objUpdateEntity.ZSECURITY_CODE4;
_Entity.USECURITY_CODE5=objUpdateEntity.ZSECURITY_CODE5;
_Entity.USECURITY_CODE6=objUpdateEntity.ZSECURITY_CODE6;

					_Entity.DATA_STATUS_CODE="Verified";

				}else{
					_Entity.Exceptions.Add(new LogisticException("VQT_NO","DataNotFd"));
				}
			}else{
				_Entity.Exceptions.Add(new LogisticException("VQT_NO","DataNotFd"));
			}
			return _Entity;
		}

		public  UID02802AE Delete(UID02802AE _Entity)
		{
			if (_DocsPermission.AccessRight("UID02802A", this.ZZLOGON_ID, "DELETE")==false)
			{
				_Entity.Exceptions.Add(new LogisticException("UID02802A","NotDeleteRight"));
				return _Entity;
			}
			_Entity.ATVT_CODE="DELETE";

					if (_Entity.VQT_NO=="")
					{
						_Entity.Exceptions.Add(new LogisticException("VQT_NO","DataMiss"));
						return _Entity;
					}

				objRetrieveEntity=new CriteriaRetrieve(typeof(VQTHDTMEntity));
			objCondition=objRetrieveEntity.NewCondition();

					objCondition.Equals("VQT_NO", _Entity.VQT_NO);

			_DataPermission.DeleteCondition(objCondition);

			EntityObject objDeleteEntity=this.Trans.RetrieveEntity(objRetrieveEntity);

			if (objDeleteEntity != null)
			{
				if (objDeleteEntity.Verified)
				{
						this.Trans.DeleteEntity(objDeleteEntity);

	CriteriaRetrieve objDetailEntity=new CriteriaRetrieve(typeof(VQTDTLMEntity));
	objCondition=objDetailEntity.NewCondition();
	objCondition.Equals("VQT_NO",_Entity.VQT_NO);

	List<EntityObject>  objDetailContainer = this.Trans.RetrieveEntitys(objDetailEntity);

	for (int i=0;i<objDetailContainer.Count;i++){
		VQTDTLMEntity objVQTDTLMEntity=(VQTDTLMEntity)objDetailContainer[i];
		this.Trans.DeleteEntity(objVQTDTLMEntity);
	}

						StringBuilder delete_cmd=new StringBuilder(this.ZZLOGON_ID+"UID02802A-DELETED=");
							delete_cmd.Append("VQT_NO="+_Entity.VQT_NO);

					ZZTrace.Debug("DELETED_LOG",delete_cmd.ToString());

				}else{
					_Entity.Exceptions.Add(new LogisticException("VQT_NO","DataNotFd"));
					return _Entity;
				}
			}else{
				_Entity.Exceptions.Add(new LogisticException("VQT_NO","DataNotFd"));
			}
			return _Entity;

		}

		public UID02802AE UserDefine(VContexts cMethod,UID02802AE _Entity)
		{
				return _Entity;
		}

#region Field
			private CriteriaRetrieve objRetrieveEntity;
		private List<EntityObject>  objEntityContainer;
		private Condition        objCondition;
		private ZZDefault        objDefault      = new ZZDefault();
		private ZZDataPermission _DataPermission = new ZZDataPermission();
		private ZZDocsPermission _DocsPermission = new ZZDocsPermission();
		private ZZSetting        _Setting        = new ZZSetting();
		private XConvert         _Convert        = new XConvert();

#endregion

			const  string ZFILE_NAME   ="UID02802AM";
		const  string MUKI_EDITION ="MIN";

	}
}
